<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="/common/header::commonHead(${title})">
</head>
<body>
<div class="agileits-modal modal fade" id="myModal88" tabindex="-1" role="dialog" aria-labelledby="myModal88"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel"><i class="fa fa-map-marker" aria-hidden="true"></i> Location
                </h4>
            </div>
            <div class="modal-body modal-body-sub">
                <h5>Select your delivery city & location </h5>

                <input type="text" name="Name" placeholder="Enter your area / Landmark / Pincode" required="">
                <button type="button" class="close2" data-dismiss="modal" aria-hidden="true">Skip & Explore</button>
            </div>
        </div>
    </div>
</div>
<div th:replace="/common/nav::nav">
</div>

<!-- 内容开始处 -->
<!-- sign up-page -->
<div class="login-page">
    <div class="container">
     <table class="table table-striped">
       <tr>
           <td>收货人</td>
           <td>收货地址</td>
           <td>联系电话</td>
           <td>下单时间</td>
           <td>订单状态</td>
           <td>功能</td>
       </tr>
         <tr th:each="mo:${myOrder}">
             <td th:text="${mo.receiveName}">
             <td th:text="${mo.address}">
             <td th:text="${mo.userPhone}">
             <td th:text="${mo.dateFormatTime}">
             <td th:text="${mo.orderState}">
             <td>
             <div class="btn-toolbar" role="toolbar">
             <div class="btn-group">
                 .<button type="button" class="btn btn-default bt-fukuan" th:attr="id=${mo.id}">付款</button>
                 <button type="button" class="btn btn-default bt-shouhuo" th:attr="id=${mo.id}">收货</button>
             </div>
             </div>
             </td>
         </tr>
     </table>
    </div>
</div>


<div th:replace="/common/footer::onloadJs"></div>
<script type="text/javascript">
    (function ($) {
        var index_function = function () {
            var self = this;
            this.body = $(document.body);
            this.body.delegate(".bt-fukuan", "click", function () {
                self.payment($(this));
            });
            this.body.delegate(".bt-shouhuo","click",function () {
                self.takeDeliver($(this));
            })
        };
        index_function.prototype = {
            test: function () {
                yy_init("model");
            },
            payment:function (obj) {
                        var self = this;
                        var id=obj.attr("id")
                        $.ajax({
                            url:"/payment",
                            type:"GET",
                            dataType:"json",
                            data:{"id":id},
                            success:function (data) {
                                if(data.text == "ok"){
                                    yy_init("付款成功");
                                    location.href = "/myOrders";
                                }else{
                                    yy_init(data.text);
                                }
                            },
                    error:function (data, status, e) {
                        console.log(e);
                    }
                });
            },

            takeDeliver:function (obj) {
                var self = this;
                var id=obj.attr("id")
                $.ajax({
                    url:"/takeDeliver",
                    type:"GET",
                    dataType:"json",
                    data:{"id":id},
                    success:function (data) {
                        if(data.text == "ok"){
                            yy_init("付款成功");
                            location.href = "/myOrders";
                        }else{
                            yy_init(data.text);
                        }
                    },
                    error:function (data, status, e) {
                        console.log(e);
                    }
                });
            }
        },
        window['index_function'] = index_function;
    })(jQuery);
    $(function () {
        var index = new index_function();
    });
</script>
</body>
</html>